# -*- coding: utf-8 -*-
import cv2 as cv
import time
from mediapipe.python.solutions import drawing_utils, hands


cap = cv.VideoCapture("videos/hand1.mp4")

mpHands = hands.Hands(min_detection_confidence=0.8, min_tracking_confidence=0.5)
mpDrawspec = drawing_utils.DrawingSpec(thickness=1, circle_radius=1)

while True:
    flag, frame = cap.read()

    frameRGB = cv.cvtColor(frame, cv.COLOR_BGR2RGB)
    results = mpHands.process(frameRGB)

    if not results.multi_hand_landmarks:
        continue

    for handlms in results.multi_hand_landmarks:
        # drawing_utils.draw_landmarks(frame, handlms, hands.HAND_CONNECTIONS)
        drawing_utils.draw_landmarks(frame, handlms, hands.HAND_CONNECTIONS, mpDrawspec, mpDrawspec)

    cv.imshow("video", frame)

    if cv.waitKey(10) & 0xFF == ord('q'):
        break

cap.release()
cv.destroyAllWindows()